/*
 * @Description: 表格工具栏配置
 * @Author: HuiSir<https://gitee.com/huisir001>
 * @Date: 2025-07-28 21:55:31
 * @LastEditTime: 2025-09-15 18:09:09
 */
import { defineToolsOptions } from "@/components/TablePage/predefined";
import useEditOptions from "./useEditOptions";
import useSearchOptions from "./useSearchOptions";
import { addAdmin } from "@/api/sys";

/* eslint-disable @typescript-eslint/no-explicit-any */
export default defineToolsOptions((getRoleList: () => Awaitable<any>) => ({
  tools: ["add", "search", "export", "refresh", "cols"],
  searchFormParams: {
    id: "",
    accountNo: "",
    name: "",
    phone: "",
    sex: "M",
    status: "",
    dateRange: "",
  } as AdminInfo,
  searchFormOptions: useSearchOptions(),
  addDialogProps: { title: "新增管理员账号", labelWidth: 60 },
  addFormOptions: useEditOptions(),
  addFormDefaultData: {
    deptId: "none",
    status: "1",
  },
  beforeShowAddDialog: async (formData, addDialogOptions) => {
    // 新增管理员时需配置密码
    addDialogOptions.value.find((item) => item.key == "password")!.hide = false;
    // 重新拉取角色
    await getRoleList();
  },
  addRequest: addAdmin,
}));
